<html>
<head>
<title>NES ASM - Day 15</title>
</head>
<body bgcolor="lavender">
<h1 align="center" style="color: LightCoral; width: 100%; filter:shadow()">Day 15 - The Noise Channel</h1>
<pre>


</pre>
<h2 align="center" style="color: LightCoral;"><b>Intro</b></h2>
<p style="color: green;"><pre><b>
	The noise channel is channel number 4 and outputs, well, a "noisy" sound.
As with all the sound stuff I talk about here, the info comes from <a href="http://nesdev.parodius.com/NESSOUND.txt">The NES Sound Doc</a>.

	The technical description of what the "noise" is, is random frequencies. The 
reason this isn't described with the other sound channels is for 3 reasons:
	
	1) Doing less at once.
	2) Noise is slightly different from the others.
	3) I felt like it.

<h3 align="center" style="color: LightCoral;"><b>Features</b></h3>
	The features of the noise channel are as follows:

	1) 29.3 Hz to 447 KHz
	2) Noisy sounds

On to the registers!
<h3 align="center" style="color: LightCoral;"><b>The Registers</b></h3>
<h5 align="center" style="color: green;">a.k.a Donde vas con este?</h5>
	The Noise Channel registers are at $400C-$400F; the noise channel is enabled
with (setting to 1) bit #3 of $4015. Let's see what they do! :)

<h4 align="center" style="color: green;">$400C</h4>
	Register $400C is the same as $4000, except bits #6-7 are unused.

<h4 align="center" style="color: green;">$400D</h4>
	Register $400D is totally <u>unused</u>.

<h4 align="center" style="color: green;">$400E</h4>
	Register $400E controls how fast the frequency goes from random frequency to
random frequency or something like that, I'm not sure. The sound doc describes it as
"playback sample rate". The bits are:

	Bits #0-3 (a.k.a the first hex digit): "playback sample rate".
	Bits #4-6 : unused. Can stay zero (0).
	Bit  #7 : "random number type generation", as far as I can tell a 1 is higher
sounding noise, a 0 is lower sounding noise. Since this is bit #7 and Bits #4-6 are
unused, we can just make a 0 or a 1 be the second hex digit.

<h4 align="center" style="color: green;">$400F</h4>
	Register $400F is the same as $4003 (except first 3 bits are unused), I 
just write whatever to it. You can still write #$AB to it if you want, I guess.

	If you really want to know, I'm not sure what it means, but bits #3-7 are
the "length counter load value". This may or may not have something to do with the
frequency.

<h4 align="center" style="color: green;">$4015</h4>
	To enable the Noise Channel, set bit #3 in $4015. Like so:

	lda #%00001000
	sta $4015

<h4 align="center" style="color: green;">The Full Code</h4>
	Again, I'll make a full code listing just because I'm way too much of
a nice guy. Here it is:

;;---CODE START---;;

	.inesprg 1
	.inesmap 0
	.inesmir 1
	.ineschr 0  ; note that we have no CHR-ROM bank in this code
	
	.bank 1
	.org $FFFA
	.dw 0 ; no VBlank routine
	.dw Start 
	.dw 0 ; we'll get to this at a later time

	.bank 0
	.org $8000
; note that I just copy/pasted code from the register sections
Start:
	lda #$FF   ; Like $4000 we just write all 1s 'cause
	sta $400C  ; we don't mind all the stuff in there being "on".

	lda #$50   ; play rate of 5 (5), lower sounding mode (0)
	sta $400E

	lda #$AB
	sta $400F

	lda #%00001000  ; enable Noise Channel
	sta $4015

infinite:
	jmp infinite

	;;--- END OF CODE FILE ---;;

Assemble and <u>Listen</u>! That code is just a modified version of the previous code
file in Day 14. This code sounds like static, I realize thats what the Noise Channel
does, but I mean this <u><i>really</i></u> sounds like radio or TV static (sorta). It
could also be water if you stretch your imagination a little.

<h3 align="center" style="color: LightCoral;"><b>This Day In Review</b></h3>

	Hope you liked that, The DMC Channel will happen when I figure it out.
So there. Hope you have fun with that! :)

Also, be sure to read through the sound doc for all the complete tech info.

	Happy listenings (again!),
		-Mike H a.k.a GbaGuy

<center><a href="nesasm.htm">Intro</a> - <a href="day16n.htm">Day 16</a></center>


</b></pre></p>

<br />
<br />

</body>
</html>
